﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//import
using ddcCajamarca.Repository.Documentos.Service;
using ddcCajamarca.BusinessEntities.Documentos;
using System.Data.Entity;

namespace ddcCajamarca.Repository.Documentos
{
    public class AreaRepository : MasterRepository, IAreaRepository
    {

        public List<Area> getAllFromAreaByCriterio(string criterio)
        {
            var query = from c in Context.Areas
                        select c;

            if (criterio != "" && criterio != null)
            {
                query = from c in query
                        where c.NombreArea.StartsWith(criterio)
                        //                  
                        select c;
            }
            return query.ToList();
        }

        public List<Area> getAllFromArea()
        {
            var query = from t in Context.Areas
                        select t;

            return query.ToList();
        }

        public Area getFromAreaById(int id)
        {
            return Context.Areas.Find(id);
        }

        public void addArea(Area area)
        {
            Context.Areas.Add(area);
            Context.SaveChanges();
        }

        public void updateArea(Area area)
        {
            Context.Entry(area).State = EntityState.Modified;
            Context.SaveChanges();
        }

        public void removeArea(int id)
        {
            throw new NotImplementedException();
        }
    }
}

